import jsonwebtoken from "jsonwebtoken";
import { logger } from '@/utils/log';
const secret = "qwz";

export const JWT = {
  generate(value: {}, exprires: string) {
    return jsonwebtoken.sign(value, secret, { expiresIn: exprires });
  },

  verify(token: string) {
    try {
        return jsonwebtoken.verify(token,secret)
    } catch (e) {
        return false
    }
  },
};


// 生成
// const token = JWT.generate({name:"wz"},'10s')
// logger.debug('生成',token)

// // 验证
// logger.debug('验证',JWT.verify(token))